package com.maixy.dailydemo.algorithm.audition;

import java.util.Arrays;

/**
 * @ClassName Test
 * @Description TODO
 * @Date 2021/2/23 20:21
 * @Author maixy
 */
public class Test {
    public static void main(String[] args) {
        Integer[] arr = new Integer[]{1, 3, 9, 7, 2};
        System.out.println(Arrays.toString(arr));

        for (int i = 0; i < arr.length - 1; i++) {
            int minIndex = i;
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[minIndex] > arr[j]) {
                    minIndex = j;
                }
            }

            if (i != minIndex) {
                Integer temp = arr[minIndex];
                arr[minIndex] = arr[i];
                arr[i] = temp;
            }
        }

        System.out.println(Arrays.toString(arr));

    }
}
